package com.ddwl.goods.dao;


import com.ddwl.common.constant.BaseEnum;
import com.ddwl.goods.dao.mapper.ActivityItemMapper;
import com.ddwl.goods.dao.model.ActivityItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.time.Instant;

@Repository
public class ActivityItemDao {
    @Autowired
    private ActivityItemMapper activityItemMapper;

    public void insert(ActivityItem activityItem){
        activityItem.setDflag(BaseEnum.DflagEnum.NOT_DELETE.getCode());
        activityItem.setGmtCreated(Instant.now());
        activityItemMapper.insert(activityItem);
    }

    public ActivityItem findByItemId(String itemId){
        return activityItemMapper.findByItemId(itemId);
    }

    public void deleteByActivityId(String activityId){
        activityItemMapper.deleteByActivityId(activityId);
    }

    public void deleteByItemId(String itemId){
        activityItemMapper.deleteByItemId(itemId);
    }



    public void update(ActivityItem activityItem){
        activityItem.setGmtCreated(Instant.now());
        activityItemMapper.update(activityItem);
    }
}
